#include <iostream>

using namespace std;

class RationalNumber
{
public:
    RationalNumber() {}
    RationalNumber(int numerator, int denominator = 1)
        : m_numerator(numerator), m_denominator(denominator)
    {
    }

    RationalNumber operator+(const RationalNumber &other) const
    {
        RationalNumber ret;
        ret.setNumerator(m_numerator * other.m_denominator + other.m_numerator * m_denominator);
        ret.setDenominator(m_denominator * other.m_denominator);
        return ret;
    }

    RationalNumber operator-(const RationalNumber &other) const
    {
        RationalNumber ret;
        ret.setNumerator(m_numerator * other.m_denominator - other.m_numerator * m_denominator);
        ret.setDenominator(m_denominator * other.m_denominator);
        return ret;
    }

    RationalNumber operator*(const RationalNumber &other) const
    {
        RationalNumber ret;
        ret.setNumerator(m_numerator * other.m_numerator);
        ret.setDenominator(m_denominator * other.m_denominator);
        return ret;
    }

    RationalNumber operator/(const RationalNumber &other) const
    {
        RationalNumber ret;
        ret.setNumerator(m_numerator * other.m_denominator);
        ret.setDenominator(m_denominator * other.m_numerator);
        return ret;
    }

    void setNumerator(int num)
    {
        m_numerator = num;
    }

    int getNumerator() const
    {
        return m_numerator;
    }

    void setDenominator(int num)
    {
        m_denominator = num;
    }

    int getDenominator() const
    {
        return m_denominator;
    }

private:
    int m_numerator = 0;
    int m_denominator = 0;
};

ostream& operator<<(ostream &os, const RationalNumber &num)
{
    os << "RationalNumber(" << num.getNumerator() << "/" << num.getDenominator() << ")";
    return os;
}

istream& operator>>(istream &is, RationalNumber &num)
{
    int numerator(0), denominator(0);
    is >> numerator >> denominator;
    num.setNumerator(numerator);
    num.setDenominator(denominator);
    return is;
}

int main()
{
    RationalNumber num1(1, 2);
    RationalNumber num2(1, 3);
    cout << num1 << endl;
    cout << num2 << endl;
    cout << num1 + num2 << endl;
    cout << num1 - num2 << endl;
    cout << num1 * num2 << endl;
    cout << num1 / num2 << endl;
    return 0;
}
